﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Microsoft.Media.IngestClient
{
    /// <summary>
    /// Provides properties for getting the standard names for media subtypes.
    /// </summary>
    public static class MediaEncodingSubtypes
    {
        /// <summary>
        /// Gets the name for Advanced Audio Coding (AAC).
        /// </summary>
        public static string Aac { get { return "Aac"; } }
        /// <summary>
        /// Gets the name for MPEG-1.
        /// </summary>
        public static string Mpeg1 { get { return "Mpeg1"; } }
        /// <summary>
        /// Gets the name for PCM.
        /// </summary>
        public static string Pcm { get { return "Pcm"; } }
        /// <summary>
        /// Gets the name for Windows Media Audio 8.
        /// </summary>
        public static string Wma8 { get { return "Wma8"; } }
        /// <summary>
        /// Gets the name for Windows Media Audio 8.
        /// </summary>
        public static string Wma9 { get { return "Wma9"; } }
        /// <summary>
        /// The name for H.264.
        /// </summary>
        public static string H264 { get { return "H264"; } }
    }

    /// <summary>
    /// Describes the format of a media stream or media container.
    /// </summary>
    public interface IMediaEncodingProperties
    {
        /// <summary>
        /// Gets or sets the subtype of the format.
        /// </summary>
        string Subtype { get; set; }

        /// <summary>
        /// Gets the format type.
        /// </summary>
        string Type { get; }
    }

    /// <summary>
    /// Represents ratios used in media operations.
    /// </summary>
    public sealed class MediaRatio
    {
        /// <summary>
        /// The denominator of the MediaRatio.
        /// </summary>
        public uint Denominator { get; set; }
        
        /// <summary>
        /// The numerator of the MediaRatio
        /// </summary>
        public uint Numerator { get; set; }
    }

    /// <summary>
    /// Describes the format of a video stream.
    /// </summary>
    public sealed class VideoEncodingProperties : IMediaEncodingProperties
    {
        /// <summary>
        /// Creates a new instance of the VideoEncodingProperties class.
        /// </summary>
        public VideoEncodingProperties()
        {
            Type = "Video";
            FrameRate = new MediaRatio();
            PixelAspectRatio = new MediaRatio();
        }

        /// <summary>
        /// Gets or sets the video bit rate.
        /// </summary>
        public uint Bitrate { get; set; }
        
        /// <summary>
        /// Gets or sets the video frame rate.
        /// </summary>
        public MediaRatio FrameRate { get; set; }
        
        /// <summary>
        /// Gets or sets the video image height.
        /// </summary>
        public uint Height { get; set; }
        
        /// <summary>
        /// Gets or sets the pixel aspect ratio.
        /// </summary>
        public MediaRatio PixelAspectRatio { get; set; }
        
        /// <summary>
        /// Gets or sets the subtype of the format.
        /// </summary>
        public string Subtype { get; set; }
        
        /// <summary>
        /// Gets the format type.
        /// </summary>
        public string Type { get; private set; }
        
        /// <summary>
        /// Gets or sets the video image width.
        /// </summary>
        public uint Width { get; set; }
    }

    /// <summary>
    /// Describes the format of an audio stream.
    /// </summary>
    public class AudioEncodingProperties : IMediaEncodingProperties
    {
        /// <summary>
        /// Creates a new instance of the AudioEncodingProperties class.
        /// </summary>
        public AudioEncodingProperties()
        {
            Type = "Audio";
        }

        /// <summary>
        /// Gets or sets the audio bit rate.
        /// </summary>
        public uint Bitrate { get; set; }
        
        /// <summary>
        /// Gets or sets the number of bits per audio sample.
        /// </summary>
        public uint BitsPerSample { get; set; }
        
        /// <summary>
        /// Gets or sets the number of audio channels.
        /// </summary>
        public uint ChannelCount { get; set; }
        
        /// <summary>
        /// Gets or sets audio sampling rate.
        /// </summary>
        public uint SampleRate { get; set; }
        
        /// <summary>
        /// Gets or sets the subtype of the format.
        /// </summary>
        public string Subtype { get; set; }
        
        /// <summary>
        /// Gets the format type.
        /// </summary>
        public string Type { get; private set; }
    }
}
